Skip to content

Add logging for experimental features - #9109

Merged
davepagurek merged 10 commits into
mainfrom
experimental-features
Aug 28, 2026
Merged

Add logging for experimental features#9109
davepagurek merged 10 commits into
mainfrom
experimental-features

Conversation

@davepagurek

@davepagurek davepagurek commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Resolves #9108

Changes:

  • Adds a decorator system for marking experimental functionality in p5
  • Sets up strands and webgpu entrypoints as experimental
  • Updates the contributor docs for strands and webgpu to be better landing pages for users coming from those experimental function warnings

Live example: https://editor.p5js.org/davepagurek/sketches/p1c5jvRAf

image

PR Checklist

@Vaivaswat2244 Vaivaswat2244 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @davepagurek , I had a few thoughts on this.

Comment thread src/webgl/material.js
fn.buildMaterialShader = function (cb, scope) {
return this.baseMaterialShader().modify(cb, scope);
};
p5.registerDecorator('p5.prototype.buildMaterialShader', markExperimental('p5.strands', p5));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildNormalShader also has beta tag, that should also be here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, good catch!

Comment thread src/core/p5.Renderer3D.js
}
return this._renderer.createStorage(dataOrCount);
};
p5.registerDecorator('p5.prototype.createStorage', markExperimental('webgpu', p5));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseComputeShader() (L2379) and compute() (L2725) are @beta and live on Renderer3D, so they are reachable in WEBGL mode where the RendererWebGPU constructor warning never fires...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compute shaders only actually work in WebGPU mode and will throw an error in WebGL mode so I figured that path was less critical to flag.

@ksen0 ksen0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these very helpful documentation updates! I've added some small but major notes re: error message. The important thing with experimental features is being transparent that API may not be stable.

Comment thread src/core/experimental.js Outdated
*/

const experimentalMessages = {
webgpu: 'WEBGPU mode is experimental. Your feedback will help direct its development!',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"WEBGPU mode is experimental, and API related to it (functions and constraints) may change in future versions. You can get involved by giving feedback to help direct its development!"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do constraints refer to in this context?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry "constants"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be rephrased I am just trying to be explicit that API may change (and that means functions or constants may change) in the future

Comment thread src/core/experimental.js Outdated

const experimentalMessages = {
webgpu: 'WEBGPU mode is experimental. Your feedback will help direct its development!',
'p5.strands': 'p5.strands shaders are experimental. Your feedback will help shape its future!',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liekwise "p5.strands API (build shader functions, the hooks in them, and related constants) may change in future versions. You can get involved by giving feedback to help shape its future!"

Comment thread src/webgl/material.js
fn.buildStrokeShader = function (cb, scope) {
return this.baseStrokeShader().modify(cb, scope);
};
p5.registerDecorator('p5.prototype.buildStrokeShader', markExperimental('p5.strands', p5));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trick that you may or may not want to use (I only just thought of it so it may not work) which is that the pattern matcher (first argument) can be a function and if it returns true the decorator will apply and false it won't, which means that if say you add some flags onto the functions itself to mark it as experimental:

p5.prototype.buildStrokeShader.experimental = true

you can just call registerDecorator once and return true whenever the flag is present on a function. That way you don't have to call registerDecorator every time a new experimental API is added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's an interesting idea! I'm going to keep it as is for now because sometimes addons augment our functions by doing something like:

let oldMethod = p5.prototype.buildStrokeShader;
p5.prototype.buildStrokeShader = function(...args) {
  // ... do something
  oldMethod.apply(this, args)
}

...and that might accidentally make the property not be visible, or at least makes it a bit more complicated. But I'm thinking this might be a good way to implement FES on p5.strands functions that don't work quite like normal functions, and where the overriding is more dynamic. So I will definitely be revisiting this!

@davepagurek
davepagurek merged commit 522b89e into main Aug 28, 2026
7 checks passed
@davepagurek
davepagurek deleted the experimental-features branch August 28, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better labelling of usage of experimental functionality

4 participants